/*
 * Copyright (c) 2015 qunar. All Rights Reserved.
 */
package com.guoyu.project.model.enums;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @author: libo Date: 15-6-7 Time: 下午5:43
 */
public enum NewsType implements ArticleMinorType {
    /**
     * 前沿要闻
     */
    FRONT(1, "前沿要闻"),
    /**
     * 地方新声
     */
    LOCAL(2, "地方新声"),
    /**
     * 高校动态
     */
    COLLEGE(3, "高校动态"),
    /**
     * 域外传真
     */
    EXTRATERRITORIAL(4, "域外传真"),;

    @JsonProperty
    private int code;
    @JsonProperty
    private String desc;

    NewsType(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    public String getDesc() {
        return desc;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return this.name();
    }

    static Map<Integer, NewsType> codeMapper = Maps.newHashMap();
    static Map<NewsType, String> descMapper = Maps.newHashMap();
    static {
        for (NewsType newsType : values()) {
            codeMapper.put(newsType.getCode(), newsType);
            descMapper.put(newsType, newsType.getDesc());
        }
    }

    public static NewsType codeOf(int code) {
        return codeMapper.get(code);
    }

    public static Map<NewsType, String> getDescMapper() {
        return descMapper;
    }
}
